All Questions
Tagged with arraypython-3.x
39 questions
5votes
4answers
2kviews
Automate the boring stuff with python - Character picture grid
Character Picture Grid Say you have a list of lists where each value in the inner lists is a one-character string, like this: ...
0votes
1answer
36views
Mangle words to bytearray of lo/hibytes
I would like to refactor the following code snippet adapted from a project I'm involved. It is part of a code to control power outlets via network. The code snippet was written by myself based on the ...
3votes
1answer
848views
Divide array into three disjoint sets with equal sum
Problem definition : Array partition problem Given an array of positive integers, divide it into three disjoint subsets having equal sum. These disjoint sets cover the complete array. Example Input: [...
2votes
2answers
79views
Send an array of files and return the first one that exists
I have a little project, chuy, which is basically a copy of Make. By request of users I have added support for toml configuration, since originally it only accepted ...
4votes
1answer
105views
Dataframe transformation to numpy ndarray takes ages to complete
I would like to transform my dataframe into an array of fixed-sized chunks from each unique segment. Specifically, I would like to transform the ...
3votes
1answer
73views
Generating multiple new arrays using numpy
Say I have the following two different states: state1 = [0, 1, 0, 1, 1] state2 = [1, 1, 0, 0, 1] And I want to generate n number of new states by only changing the ...
3votes
2answers
537views
Multiplying numpy arrays
I have written a function to multiply two numpy arrays. ...
8votes
2answers
776views
Optimize function that returns length of a subarray
I did an exercise today on where the task is to write a function that returns the length of the longest subarray where the difference between the smallest and biggest value in the subarray is no more ...
3votes
1answer
82views
The problem “Fun game” from a competition
I recently began to learn Python and encountered this problem. The condition: You and your friends are playing the next game. Friends write 𝑁 natural numbers in a ...
5votes
1answer
352views
Applying gaussian blur on RGBA images
I designed the code and it works quite well for images of lower res. However my program takes a lot of time and ram to display higher res images (occupies 2GB RAM for 4k images and takes 20 minutes). ...
2votes
1answer
839views
Re-implementing an Array Class in Python
I gave an attempt at reinventing the wheel and recreate list methods using my own Array Class to broaden my understanding about lists. I would like advice regarding efficiency, and in implementing ...
2votes
1answer
373views
Dice roller - python
I am about to graduate with my Associates degree in Math and will soon go for my bachelors. I've decided with two years of school left its best if I start learning to program. I am starting with ...
0votes
2answers
741views
Find the maximum value of | Ai - Aj | + | i - j |: [closed]
hackerearth.com practice problem Can you solve it?: Given an array 'A' consisting of 'n' integers, find the maximum value of the following expression: \$\lvert A_i - A_j\rvert + \lvert i - j\rvert\...
3votes
3answers
657views
Given an array, find all its elements that can become a leader
I was successful in solving a challenge in codility, but my solution failed performance tests. How can I improve my solution? Challenge: Integers K, M and a non-empty array A consisting of N ...
1vote
2answers
506views
Maximum contiguous sum in an array
The following code is my solution for the following Daily Coding Challenge Given an array of numbers, find the maximum sum of any contiguous subarray of the array. For example, given the ...